/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.sms.service;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.chlitina.store.common.persistence.Page;
import com.chlitina.store.common.service.BaseService;
import com.chlitina.store.modules.sms.dao.StoreRechargeSmsLogDao;
import com.chlitina.store.modules.sms.entity.StoreRechargeSmsLog;

/**
 * 店面短信充值日志Service
 * @author lvbo
 * @version 2013-07-12
 */
@Component
@Transactional(readOnly = true)
public class StoreRechargeSmsLogService extends BaseService {

	@SuppressWarnings("unused")
	private static Logger logger = LoggerFactory.getLogger(StoreRechargeSmsLogService.class);
	
	@Autowired
	private StoreRechargeSmsLogDao storeRechargeSmsLogDao;
	
	public StoreRechargeSmsLog get(Long id) {
		return storeRechargeSmsLogDao.findOne(id);
	}
	
	public Page<StoreRechargeSmsLog> find(Page<StoreRechargeSmsLog> page, StoreRechargeSmsLog storeRechargeSmsLog) {
		DetachedCriteria dc = storeRechargeSmsLogDao.createDetachedCriteria();
		if (storeRechargeSmsLog.getStore()!=null && storeRechargeSmsLog.getStore().getId()>0){
			dc.add(Restrictions.eq("store.id", storeRechargeSmsLog.getStore().getId()));
		}
		dc.add(Restrictions.eq("delFlag", StoreRechargeSmsLog.DEL_FLAG_NORMAL));
		dc.addOrder(Order.desc("id"));
		return storeRechargeSmsLogDao.find(page, dc);
	}
	
	@Transactional(readOnly = false)
	public void save(StoreRechargeSmsLog storeRechargeSmsLog) {
		storeRechargeSmsLogDao.save(storeRechargeSmsLog);
	}
	
	
}
